package cn.itcast.bos.service.transit.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.itcast.bos.dao.transit.DeliveryInfoRepository;
import cn.itcast.bos.dao.transit.TransitInfoRepository;
import cn.itcast.bos.domain.transit.DeliveryInfo;
import cn.itcast.bos.domain.transit.TransitInfo;
import cn.itcast.bos.service.transit.DeliveryInfoService;
@Service
@Transactional
public class DeliveryInfoServiceImpl implements DeliveryInfoService {
	@Resource
	private DeliveryInfoRepository repository;
	@Resource
	private TransitInfoRepository transitInfoRespository;
	@Override
	public void save(String transitInfoId, DeliveryInfo model) {
		//保存开始配送的信息
		repository.save(model);
		
		//查询运输配送对象
		TransitInfo transitInfo = transitInfoRespository.findOne(Integer.parseInt(transitInfoId));
		//关联配送信息
		transitInfo.setDeliveryInfo(model);
		
		//更改状态
		transitInfo.setStatus("开始配送");
	}

}
